package com.winit.requirement.repository;

import com.winit.requirement.model.ReqRemark;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface ReqRemarksRepository extends CrudRepository<ReqRemark, String>{
    @Query(value = "select * from matrix_req_remarks where 1 = 1 and (?1 is null or  id = ?1) and (?2 is null or number = ?2) and (?3 is null or req_id = ?3)", nativeQuery = true)
    List<ReqRemark> findByProperties(String id, String number, String reqId);
//    @Modifying
//    @Transactional
//    @Query(value = "update matrix_requirements mr set mr.req_is_del = ?2 where mr.brd_id = ?1", nativeQuery = true)
//    int updateIsDeletedByBrdId(String brdId, String isDel);
//    @Query(value = "select mr.* from matrix_requirements mr where 1=1 AND(?1 is null or mr.brd_id=?1) AND(?2 is null or mr.project_plan_id=?2) AND(?3 is null or mr.req_id=?3) AND mr.req_is_del <> ?4 order by mr.req_create_time desc", nativeQuery = true)
//    List<BrdRequirement> searchBrdRequirements(String brdId, String projectPlanId, String reqId, String excludeIsdel);
//
//
//
//    @Modifying
//    @Transactional
//    @Query(value = "update matrix_requirements mr set mr.project_plan_id = ?2, mr.req_status = ?3 where mr.project_plan_id=?1", nativeQuery = true)
//    int updateProjectPlanIdAndBrdStatusByProjectPlanId(String oriProjectPlanId, String targetProjectPlanId, String projectPlanStatus);
//
//    @Modifying
//    @Transactional
//    @Query(value = "update matrix_requirements mr set mr.project_plan_id = ?2, mr.req_status = ?3 where mr.req_id in ?1", nativeQuery = true)
//    int updateProjectPlanIdAndBrdStatusByReqIds(List<String> reqIds, String projectPlanId, String brdStatus);
//
//    @Modifying
//    @Transactional
//    @Query(value = "update matrix_requirements mr set mr.project_plan_id = ?2, mr.req_status = ?3 where mr.req_id = ?1", nativeQuery = true)
//    int updateProjectPlanIdAndBrdStatusByReqId(String reqId, String projectPlanId, String status);
}
